import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.util.Vector;
import java.util.Random;

public class DB_tune {
    public static int hash(int key) {
        return key;
    }

    public static int Pow(int a, int b) {
        int r = 1;
        for (int i = 0; i < b; i++) {
            r = r * a;
        }
        return r;
    }

    public static void main(String[] args) throws Exception {
        int size=256;
        TestDataGenerator testDataGenerator = new TestDataGenerator(size,"DataTest/test_01");
        testDataGenerator.generator();

        int num = 500;
        Student[] record = new Student[num];
//        Random random=new Random();
        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream("Data/test_data1.txt")));
        String str = null;
        int count = 0;
        while ((str = in.readLine()) != null) {
            String curLine[] = str.split(" ");
            record[count++] = new Student(Integer.parseInt(curLine[0]), curLine[1], Integer.parseInt(curLine[2]));
        }
        int x = 100, y = 10;
        int[][] bucket = new int[x][y];
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                bucket[i][j] = -1;
            }
        }
        int N = 2, L = 0, S = 0, n = 2;
        int H = 0, r = 0;
        int addr = 0;
        int split = 0;
        for (int i = 0; i < count; i++) {
            H = hash(record[i].getId());
            addr = H % (N * Pow(2, L));
            if (addr < S) {
                addr = H % (N * Pow(2, L + 1));
            }
            for (int j = 0; j < y; j++) {
                if (bucket[addr][j] == -1) {
                    bucket[addr][j] = H;
                    r++;
                    break;
                }
            }
            if (r * 1.0 / n > 1.7) {
                n++;
                split = S;
                if (S == N * Pow(2, L) - 1) {
                    S = 0;
                    L++;
                } else {
                    S++;
                }
                for (int j = 0; j < y; j++) {
                    if (bucket[split][j] != -1) {
                        int v = bucket[split][j];
                        bucket[split][j] = -1;
                        addr = v % (N * Pow(2, L));
                        if (addr < S) {
                            addr = v % (N * Pow(2, L + 1));
                        }
                        for (int k = 0; k < y; k++) {
                            if (bucket[addr][k] == -1) {
                                bucket[addr][k] = v;
                                break;
                            }
                        }
                    }
                }


            }
            for(int k=0;k<n;k++){
                System.out.print("bucket"+k+": ");
                for(int t=0;t<y;t++){
                    if(bucket[k][t]==-1){
                        break;
                    }else{
                        System.out.print(bucket[k][t] + " ");
                    }
                }
                System.out.println();
            }
            System.out.println("S:"+S+" L:"+L);
            System.out.println("--------------------------------第"+(i+1)+"步");
        }
        int mm = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < y; j++) {
                if (bucket[i][j] != -1) {
                    mm++;
                }
            }
        }
        System.out.println(mm);
    }
}
